#include <string>
#include <iostream>
#include <locale>
#include <codecvt>

// convert string to wstring
inline std::wstring to_wide_string(const std::string& input)
{
    std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
    return converter.from_bytes(input);
}
// convert wstring to string
inline std::string to_byte_string(const std::wstring& input)
{
    //std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
    std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
    return converter.to_bytes(input);
}

int main(void)
{
    std::string str("张三");
    std::cout << str << std::endl;
    std::cout << L"张三" << std::endl; //输出为 ：0x557585e5e714
    
    std::wstring wstr(L"张三");
    std::cout << to_byte_string(wstr) << std::endl;;

    return 0;
}
